test: parallel
	mpiexec -np 4 ./parallel 3 1 input_10.txt output_10_3.txt
	diff output_10_3.txt output_10_3.ans
	mpiexec -np 4 ./parallel 10 1 input_10.txt output_10_10.txt
	diff output_10_10.txt output_10_10.ans
	mpiexec -np 4 ./parallel 100 1 input_10.txt output_10_100.txt
	diff output_10_100.txt output_10_100.ans
	mpiexec -np 4 ./parallel 3 1 input_50.txt output_50_3.txt
	diff output_50_3.txt output_50_3.ans
	mpiexec -np 4 ./parallel 100 1 input_50.txt output_50_100.txt
	diff output_50_100.txt output_50_100.ans
	mpiexec -np 4 ./parallel 1000 1 input_50.txt output_50_1000.txt
	diff output_50_1000.txt output_50_1000.ans

debug: parallel.c
	gcc -c -g -I${TACC_PAPI_INC} parallel.c
	gcc -Wl,-rpath,${TACC_PAPI_LIB} -L${TACC_PAPI_LIB} -lpthread -lpapi parallel.o -o parallel

parallel: parallel.c
	mpicc -c -O3 -xhost -opt-prefetch -ipo -axSSE4.2 -I${TACC_PAPI_INC} parallel.c
	mpicc -Wl,-rpath,${TACC_PAPI_LIB} -L${TACC_PAPI_LIB} -lpthread -lpapi parallel.o -o parallel
serial: serial.c
	gcc -g serial.c -o serial

clean:
	rm -rf serial parallel *.dSYM otuput*.txt *.out
